﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using System.Net;
using System.Configuration;

namespace Prisa.UI.Reportes
{
    public partial class frmProductosTop : Form
    {
        public DateTime fecInicio;
        public DateTime fecFin;


        public frmProductosTop()
        {
            InitializeComponent();
        }

        private void frmProductosTop_Load(object sender, EventArgs e)
        {
            reportViewer1.ShowPageNavigationControls = false;
            reportViewer1.ShowCredentialPrompts = false;

            var user = ConfigurationManager.AppSettings.Get("userReport");
            var pws = ConfigurationManager.AppSettings.Get("pwsReport");
            reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = new NetworkCredential(user, pws);


            var ipServer = ConfigurationManager.AppSettings.Get("ipServer");
            var path = ConfigurationManager.AppSettings.Get("pathProdTop");
            reportViewer1.ProcessingMode = ProcessingMode.Remote;
            reportViewer1.ServerReport.ReportPath = path;
            reportViewer1.ServerReport.ReportServerUrl = new Uri(ipServer, System.UriKind.Absolute);


            ReportParameter[] parameters = new ReportParameter[2];
            parameters[0] = new ReportParameter("fechaInicio", fecInicio.ToShortDateString());
            parameters[1] = new ReportParameter("fechaFin", fecFin.ToShortDateString());
            reportViewer1.ServerReport.SetParameters(parameters);
            this.reportViewer1.RefreshReport();
            this.reportViewer1.RefreshReport();
        }

        public DateTime ObtenerFecha1(DateTime fec1)
        {
            fecInicio = fec1;
            return fecInicio;
        }

        public DateTime ObtenerFecha2(DateTime fec2)
        {
            fecFin = fec2;
            return fecFin;
        }


    }
}
